package com.surface.hao.component;

import javax.swing.*;
import java.awt.*;

/**
 * @Description:
 *  实现一个有scroll的面板
 * @Author: songhao
 * @Email:425008064@qq.com
 * @CreateDate: 2019/12/30 15:02
 */
public class ScrollPanel extends JPanel{

    private JPopupTextArea text = new JPopupTextArea();
    private JScrollPane scrollPanel = new JScrollPane(text);

    public ScrollPanel() {
        this.setLayout(new BorderLayout());

        text.setFont(new Font("宋体", Font.BOLD, 16));
        scrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); //设置水平滚动框一直显示
        scrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);//设置垂直滚动框一直显示
        this.add(scrollPanel, BorderLayout.CENTER);
    }

    public String getText(){
        return this.text.getText();
    }

    public void setText(String content){
        text.setText(content);
    }
}
